package com.example.controller;

import com.example.domain.message.MessageConstant;
import com.example.domain.query.QueryPageBean;
import com.example.domain.result.PageResult;
import com.example.domain.result.Result;
import com.example.service.CashService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cash") //底层是通过session实现的
public class CashController {

    @Autowired
    private CashService cashService;

    //1:确认提现
    @RequestMapping("/confirm")
    private Result cashRecord(Long id){
        //1:直接显示需要提现的订单
        System.out.println(id);
        Boolean flag=cashService.updateCashStatus(id);
        if(flag){
            return new Result(flag,MessageConstant.UPDATE_SUCCESS);
        }
        return new Result(flag,MessageConstant.UPDATE_FAIL);
    }


    @RequestMapping("/cashRecord")
    private PageResult cashRecord(@RequestBody QueryPageBean queryPageBean){
        //1:直接显示已经提现的订单
        PageResult page = cashService.findPageCashRecord(queryPageBean.getQueryString(), queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        return new PageResult(page.getTotal(),page.getRows());



    }


    //1:需要提现的
    @RequestMapping("/havaWithdrawal")
    private PageResult havaWithdrawal(@RequestBody QueryPageBean queryPageBean){
        //1:直接显示已经提现的订单
        PageResult page = cashService.findPage(queryPageBean.getQueryString(), queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        return new PageResult(page.getTotal(),page.getRows());



    }
}
